package com.kaifamiao.wendao.service;

import com.kaifamiao.wendao.dao.ExplainDao;
import com.kaifamiao.wendao.entity.Explain;
import com.kaifamiao.wendao.utils.SnowflakeIdGenerator;

import java.time.LocalDateTime;

public class ExplainService {

    private ExplainDao explainDao = new ExplainDao();
    // 获取标识符生成器(该对象在当前JVM中是单例)
    private SnowflakeIdGenerator idGenerator = SnowflakeIdGenerator.getInstance();

    public boolean save(Explain e) {
        e.setId(idGenerator.generate());
        e.setPublishTime(LocalDateTime.now());
        return explainDao.save(e);
    }

}
